package bill_management_system;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class BillManagementSystem {
    private static List<Income> incomes = new ArrayList<>();
    private static List<Expense> expenses = new ArrayList<>();
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        boolean running = true;
        while (running) {
            showMenu();
            int choice = scanner.nextInt();
            scanner.nextLine(); // Consume newline

            switch (choice) {
                case 1:
                    addIncome();
                    break;
                case 2:
                    addExpense();
                    break;
                case 3:
                    displayTransactions();
                    break;
                case 4:
                    // searchTransactions();
                    break;
                case 5:
                    // setBudget();
                    break;
                case 6:
                    // monthlyStatistics();
                    break;
                case 7:
                    running = false;
                    break;
                default:
                    System.out.println("无效选项，请重新输入！");
                    break;
            }
        }
        scanner.close();
    }

    private static void showMenu() {
        System.out.println("=================================");
        System.out.println("欢迎使用个人账单管理系统");
        System.out.println("=================================");
        System.out.println("请选择操作：");
        System.out.println("1. 记录收入");
        System.out.println("2. 记录支出");
        System.out.println("3. 查看所有账单");
        System.out.println("4. 查询账单");
        System.out.println("5. 设置月度预算");
        System.out.println("6. 查看月度统计报告");
        System.out.println("7. 退出系统");
        System.out.print("请输入选项序号：");
    }

    private static void addIncome() {
        System.out.print("请输入收入日期（YYYY-MM-DD）：");
        String date = scanner.next();
        System.out.print("请输入收入金额：");
        double amount = scanner.nextDouble();
        System.out.print("请输入收入类别（如工资、奖金等）：");
        String category = scanner.next();
        System.out.print("请输入备注：");
        scanner.nextLine(); // Consume newline
        String remark = scanner.nextLine();
        incomes.add(new Income(date, amount, category, remark));
        System.out.println("收入已成功记录！");
    }

    private static void addExpense() {
        System.out.print("请输入支出日期（YYYY-MM-DD）：");
        String date = scanner.next();
        System.out.print("请输入支出金额：");
        double amount = scanner.nextDouble();
        System.out.print("请输入支出类别（如餐饮、交通、购物等）：");
        String category = scanner.next();
        System.out.print("请输入备注：");
        scanner.nextLine(); // Consume newline
        String remark = scanner.nextLine();
        expenses.add(new Expense(date, amount, category, remark));
        System.out.println("支出已成功记录！");
    }

    private static void displayTransactions() {
        System.out.println("\n所有收入记录：");
        for (Income income : incomes) {
            System.out.println(income);
        }
        System.out.println("\n所有支出记录：");
        for (Expense expense : expenses) {
            System.out.println(expense);
        }
    }

    // 其他方法（searchTransactions, setBudget, monthlyStatistics）的实现...
}